package com.pyf.demo.controller;

import com.pyf.demo.entity.MountainEntity;
import com.pyf.demo.service.MountainService;
import com.pyf.demo.utils.PageUtils;
import com.pyf.demo.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 记录巡山人需要去巡逻的山
 *
 * @author pengyifeng
 * @email pengyifeng@aliyun.com
 * @date 2020-12-09 16:00:18
 */
@RestController
@RequestMapping("demo/mountain")
public class MountainController {
    @Autowired
    private MountainService mountainService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("demo:mountain:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = mountainService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("demo:mountain:info")
    public R info(@PathVariable("id") Integer id){
		MountainEntity mountain = mountainService.getById(id);

        return R.ok().put("mountain", mountain);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("demo:mountain:save")
    public R save(@RequestBody MountainEntity mountain){
		mountainService.save(mountain);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("demo:mountain:update")
    public R update(@RequestBody MountainEntity mountain){
		mountainService.updateById(mountain);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("demo:mountain:delete")
    public R delete(@RequestBody Integer[] ids){
		mountainService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
